how to call apis with javascript